/*
 * @Author: your name
 * @Date: 2021-01-11 09:26:16
 * @LastEditTime: 2021-01-13 17:52:25
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \wxapp\pages\vehicle\service\service.js
 */
 var t = getApp(),
  e = t.requirejs("core");
t.requirejs("foxui");
Page({
    data: {
        imgUrls: ["/static/images/service.jpg","/static/images/service.jpg"],
        list: [
            /*{
                imageSrc: "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2542054890,4291997804&fm=26&gp=0.jpg",
                title: "益众汽车维修服务中心",
                subTitle: "1782904893939",
                address: "惠州市惠城区解放路11号"
            },
            {
                imageSrc: "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2542054890,4291997804&fm=26&gp=0.jpg",
                title: "吉顺通汽车维修服务中心",
                subTitle: "1782904893939", address: "惠州市惠城区解放路11号"

            },
            {
                imageSrc: "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2542054890,4291997804&fm=26&gp=0.jpg",
                title: "冠以汽车维修服务中心",
                subTitle: "1782904893939", address: "惠州市惠城区解放路11号"

            },
            {
                imageSrc: "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2542054890,4291997804&fm=26&gp=0.jpg",
                title: "1782904893939",
                subTitle: "大型车", address: "惠州市惠城区解放路11号"

            },
            {
                imageSrc: "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2542054890,4291997804&fm=26&gp=0.jpg",
                title: "河源汽车维修服务中心",
                subTitle: "1782904893939", address: "惠州市惠城区解放路11号"

            },
            {
                imageSrc: "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2542054890,4291997804&fm=26&gp=0.jpg",
                title: "益众汽车维修服务中心",
                subTitle: "1782904893939", address: "惠州市惠城区解放路11号"

            },
            {
                imageSrc: "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2542054890,4291997804&fm=26&gp=0.jpg",
                title: "益众汽车维修服务中心",
                subTitle: "1782904893939", address: "惠州市惠城区解放路11号"

            },*/
        ],
        lat:'',
        lng:''
    },
     onLoad: function (e) {
     var that = this;

     /*wx.getLocation({
      success: function(res) {
        that.setData({
          lat: res.latitude,
          lng: res.longitude
        })
        //调用后台API，获取地址信息
        that.getList(res.latitude,res.longitude)
        console.log(res);
      },
      fail: function (e) {
          //console.log(e);
          that.getList();
      }
    })*/
   
      
  },
  onShow: function () {
     var that = this;
     if(that.data.lat == '' || that.data.lng == ''){
      
        wx.getLocation({
          success: function(res) {
            console.log(1)
            that.setData({
              lat: res.latitude,
              lng: res.longitude
            })
            //调用后台API，获取地址信息
            that.getList(res.latitude,res.longitude)
          },
          fail: function (e) {
              //wx.openSetting();
              that.getList();
          }
        })

     }
      
  },
  getList: function (lat,lng) {
    var t = this;
    t.setData({
      loading: true,
    }),
      e.get("vehicle/shop/get_list", {
        lat:lat,
        lng:lng
      }, function (e) {
        //console.log(e);
        t.setData({
            list: e.list
        })

      })
  },
 /* call: function (e) {
    var number = e.currentTarget.dataset.mobile;
    wx.makePhoneCall({
      phoneNumber: number 
    })
   
  }*/

})